import Vue from 'vue';
import iView from 'iview';
import VueRouter from 'vue-router';
import Routers from './router';
import Vuex from 'vuex';
import Util from './libs/util';
import App from './app.vue';
import 'iview/dist/styles/iview.css';

Vue.prototype.$http=Util.ajax;
// Vue.prototype.$addDivece = {
//     comments: '新增设备测试',
//     hardwareId: 'b6daecc5-b0b2-48a8-90ab-4c4a170dd2a91',
//     metadata: {},
//     siteToken: 'bb105f8d-3150-41f5-b9d1-db04965668d3',
//     specificationToken: 'd2604433-e4eb-419b-97c7-88efe9b2cd41'
// };

Vue.use(VueRouter);
Vue.use(Vuex);
Vue.use(iView);

// 路由配置
const RouterConfig = {
    mode: 'history',
    routes: Routers
};
const router = new VueRouter(RouterConfig);

router.beforeEach((to, from, next) => {
    iView.LoadingBar.start();
    Util.title(to.meta.title);
    next();
});

router.afterEach(() => {
    iView.LoadingBar.finish();
    window.scrollTo(0, 0);
});


const store = new Vuex.Store({
    state: {

    },
    getters: {

    },
    mutations: {

    },
    actions: {

    }
});


new Vue({
    el: '#app',
    router: router,
    store: store,
    render: h => h(App)
});